<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div class="box"></div>
  </body>
</html>
<script>
  // 鼠标事件类型
  const box = document.querySelector(".box");
  // 1.鼠标点击
  box.addEventListener("click", function () {
    alert("点击");
  });

  // 2.鼠标经过出发事件
  box.addEventListener("mouseenter", function () {
    console.log("mouseenter事件");
  });

  // 3.鼠标离开出发事件
  box.addEventListener("mouseleave", function () {
    console.log("mouselive事件");
  });
</script>
